.class public Lcom/hierynomus/smbj/connection/a;
.super Les/jd0;
.source "Connection.java"

# interfaces
.implements Lcom/hierynomus/smbj/transport/b;


# instance fields
.field private f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

.field private g:Les/kd0;

.field private h:Lcom/hierynomus/smbj/transport/d;

.field private i:Lcom/hierynomus/smbj/transport/c;

.field private j:Ljava/lang/Thread;

.field private k:Ljava/util/concurrent/ConcurrentHashMap;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/concurrent/ConcurrentHashMap<",
            "Ljava/lang/Long;",
            "Lcom/hierynomus/smbj/connection/b;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Les/kd0;Lcom/hierynomus/smbj/transport/d;)V
    .locals 1

    .line 1
    invoke-interface {p2}, Lcom/hierynomus/smbj/transport/d;->a()I

    move-result v0

    invoke-direct {p0, v0}, Les/jd0;-><init>(I)V

    .line 2
    new-instance v0, Ljava/util/concurrent/ConcurrentHashMap;

    invoke-direct {v0}, Ljava/util/concurrent/ConcurrentHashMap;-><init>()V

    iput-object v0, p0, Lcom/hierynomus/smbj/connection/a;->k:Ljava/util/concurrent/ConcurrentHashMap;

    .line 3
    iput-object p1, p0, Lcom/hierynomus/smbj/connection/a;->g:Les/kd0;

    .line 4
    iput-object p2, p0, Lcom/hierynomus/smbj/connection/a;->h:Lcom/hierynomus/smbj/transport/d;

    .line 5
    sput-object p0, Les/gd0;->a:Lcom/hierynomus/smbj/transport/b;

    return-void
.end method

.method private j()V
    .locals 5
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/hierynomus/smbj/transport/TransportException;
        }
    .end annotation

    .line 1
    new-instance v0, Lcom/hierynomus/smbj/smb2/messages/h;

    iget-object v1, p0, Lcom/hierynomus/smbj/connection/a;->g:Les/kd0;

    invoke-interface {v1}, Les/kd0;->a()Ljava/util/EnumSet;

    move-result-object v1

    iget-object v2, p0, Lcom/hierynomus/smbj/connection/a;->f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

    invoke-virtual {v2}, Lcom/hierynomus/smbj/connection/ConnectionInfo;->a()Ljava/util/UUID;

    move-result-object v2

    invoke-direct {v0, v1, v2}, Lcom/hierynomus/smbj/smb2/messages/h;-><init>(Ljava/util/EnumSet;Ljava/util/UUID;)V

    .line 2
    invoke-virtual {p0, v0}, Lcom/hierynomus/smbj/connection/a;->b(Lcom/hierynomus/smbj/smb2/d;)Ljava/util/concurrent/Future;

    move-result-object v0

    .line 3
    sget-object v1, Lcom/hierynomus/smbj/transport/TransportException;->Wrapper:Les/fd0;

    invoke-static {v0, v1}, Les/gd0;->a(Ljava/util/concurrent/Future;Les/fd0;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/hierynomus/smbj/smb2/d;

    .line 4
    instance-of v1, v0, Lcom/hierynomus/smbj/smb2/messages/i;

    if-eqz v1, :cond_0

    .line 5
    check-cast v0, Lcom/hierynomus/smbj/smb2/messages/i;

    .line 6
    iget-object v1, p0, Lcom/hierynomus/smbj/connection/a;->f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

    invoke-virtual {v1, v0}, Lcom/hierynomus/smbj/connection/ConnectionInfo;->a(Lcom/hierynomus/smbj/smb2/messages/i;)V

    return-void

    .line 7
    :cond_0
    new-instance v1, Ljava/lang/IllegalStateException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Expected a SMB2 NEGOTIATE Response, but got: "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Lcom/hierynomus/smbj/smb2/d;->a()Lcom/hierynomus/smbj/smb2/c;

    move-result-object v0

    invoke-virtual {v0}, Lcom/hierynomus/smbj/smb2/c;->d()J

    move-result-wide v3

    invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-direct {v1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v1
.end method


# virtual methods
.method public a(Les/od0;)Les/qd0;
    .locals 4

    .line 1
    new-instance v0, Les/pd0$a;

    invoke-direct {v0}, Les/pd0$a;-><init>()V

    .line 2
    :try_start_0
    new-instance v1, Lcom/hierynomus/spnego/a;

    invoke-direct {v1}, Lcom/hierynomus/spnego/a;-><init>()V

    iget-object v2, p0, Lcom/hierynomus/smbj/connection/a;->f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

    invoke-virtual {v2}, Lcom/hierynomus/smbj/connection/ConnectionInfo;->c()[B

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/hierynomus/spnego/a;->a([B)Lcom/hierynomus/spnego/a;

    .line 3
    invoke-virtual {v1}, Lcom/hierynomus/spnego/a;->a()Ljava/util/List;

    move-result-object v1

    new-instance v2, Lcom/hierynomus/asn1/m;

    invoke-virtual {v0}, Les/pd0$a;->b()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Lcom/hierynomus/asn1/m;-><init>(Ljava/lang/String;)V

    invoke-interface {v1, v2}, Ljava/util/List;->contains(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 4
    invoke-virtual {v0}, Les/pd0$a;->a()Les/pd0;

    move-result-object v0

    .line 5
    invoke-virtual {v0, p0, p1}, Les/pd0;->a(Lcom/hierynomus/smbj/connection/a;Les/od0;)J

    move-result-wide v0

    .line 6
    new-instance p1, Les/qd0;

    invoke-direct {p1, v0, v1, p0}, Les/qd0;-><init>(JLcom/hierynomus/smbj/connection/a;)V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    return-object p1

    :cond_0
    const/4 p1, 0x0

    return-object p1

    :catch_0
    move-exception p1

    .line 7
    new-instance v0, Lcom/hierynomus/smbj/common/SMBRuntimeException;

    invoke-direct {v0, p1}, Lcom/hierynomus/smbj/common/SMBRuntimeException;-><init>(Ljava/lang/Throwable;)V

    throw v0
.end method

.method public a(Lcom/hierynomus/smbj/smb2/d;)V
    .locals 6
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/hierynomus/smbj/transport/TransportException;
        }
    .end annotation

    .line 8
    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/d;->b()J

    move-result-wide v0

    .line 9
    iget-object v2, p0, Lcom/hierynomus/smbj/connection/a;->k:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/concurrent/ConcurrentHashMap;->containsKey(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_2

    .line 10
    iget-object v2, p0, Lcom/hierynomus/smbj/connection/a;->f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

    invoke-virtual {v2}, Lcom/hierynomus/smbj/connection/ConnectionInfo;->d()Lcom/hierynomus/smbj/connection/c;

    move-result-object v2

    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/d;->a()Lcom/hierynomus/smbj/smb2/c;

    move-result-object v3

    invoke-virtual {v3}, Lcom/hierynomus/smbj/smb2/c;->b()I

    move-result v3

    invoke-virtual {v2, v3}, Lcom/hierynomus/smbj/connection/c;->a(I)V

    .line 11
    iget-object v2, p0, Lcom/hierynomus/smbj/connection/a;->k:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/util/concurrent/ConcurrentHashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/hierynomus/smbj/connection/b;

    .line 12
    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/d;->a()Lcom/hierynomus/smbj/smb2/c;

    move-result-object v3

    invoke-virtual {v3}, Lcom/hierynomus/smbj/smb2/c;->c()J

    move-result-wide v3

    sget-object v5, Lcom/hierynomus/smbj/smb2/SMB2MessageFlag;->SMB2_FLAGS_ASYNC_COMMAND:Lcom/hierynomus/smbj/smb2/SMB2MessageFlag;

    invoke-static {v3, v4, v5}, Les/ed0$a;->a(JLes/ed0;)Z

    move-result v3

    if-eqz v3, :cond_0

    .line 13
    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/d;->a()Lcom/hierynomus/smbj/smb2/c;

    move-result-object v3

    invoke-virtual {v3}, Lcom/hierynomus/smbj/smb2/c;->f()Lcom/hierynomus/mserref/NtStatus;

    move-result-object v3

    sget-object v4, Lcom/hierynomus/mserref/NtStatus;->STATUS_PENDING:Lcom/hierynomus/mserref/NtStatus;

    if-ne v3, v4, :cond_0

    .line 14
    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/d;->a()Lcom/hierynomus/smbj/smb2/c;

    move-result-object p1

    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/c;->a()J

    move-result-wide v0

    invoke-virtual {v2, v0, v1}, Lcom/hierynomus/smbj/connection/b;->a(J)V

    return-void

    .line 15
    :cond_0
    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/d;->a()Lcom/hierynomus/smbj/smb2/c;

    move-result-object v2

    invoke-virtual {v2}, Lcom/hierynomus/smbj/smb2/c;->f()Lcom/hierynomus/mserref/NtStatus;

    move-result-object v2

    sget-object v3, Lcom/hierynomus/mserref/NtStatus;->STATUS_NETWORK_SESSION_EXPIRED:Lcom/hierynomus/mserref/NtStatus;

    if-ne v2, v3, :cond_1

    return-void

    .line 16
    :cond_1
    iget-object v2, p0, Lcom/hierynomus/smbj/connection/a;->k:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v0

    invoke-virtual {v2, v0}, Ljava/util/concurrent/ConcurrentHashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/hierynomus/smbj/connection/b;

    invoke-virtual {v0}, Lcom/hierynomus/smbj/connection/b;->a()Les/hd0;

    move-result-object v0

    invoke-virtual {v0, p1}, Les/hd0;->a(Ljava/lang/Object;)V

    return-void

    .line 17
    :cond_2
    new-instance p1, Lcom/hierynomus/smbj/transport/TransportException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "Received response with unknown sequence number <<"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2, v0, v1}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    const-string v0, ">>"

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-direct {p1, v0}, Lcom/hierynomus/smbj/transport/TransportException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public a(Ljava/lang/Throwable;)V
    .locals 3

    const-string v0, "SMB"

    const-string v1, "connection broken or timeout!"

    .line 18
    invoke-static {v0, v1}, Lcom/estrongs/android/util/n;->b(Ljava/lang/String;Ljava/lang/String;)V

    .line 19
    invoke-virtual {p1}, Ljava/lang/Throwable;->printStackTrace()V

    .line 20
    :try_start_0
    invoke-virtual {p0}, Lcom/hierynomus/smbj/connection/a;->h()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v0

    .line 21
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    .line 22
    :goto_0
    :try_start_1
    new-instance v0, Ljava/util/HashSet;

    iget-object v1, p0, Lcom/hierynomus/smbj/connection/a;->k:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-virtual {v1}, Ljava/util/concurrent/ConcurrentHashMap;->keySet()Ljava/util/Set;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/util/HashSet;-><init>(Ljava/util/Collection;)V

    invoke-virtual {v0}, Ljava/util/HashSet;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :goto_1
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/Long;

    .line 23
    iget-object v2, p0, Lcom/hierynomus/smbj/connection/a;->k:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-virtual {v2, v1}, Ljava/util/concurrent/ConcurrentHashMap;->remove(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/hierynomus/smbj/connection/b;

    invoke-virtual {v1}, Lcom/hierynomus/smbj/connection/b;->a()Les/hd0;

    move-result-object v1

    invoke-virtual {v1, p1}, Les/hd0;->a(Ljava/lang/Throwable;)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    goto :goto_1

    :catch_1
    move-exception p1

    .line 24
    invoke-virtual {p1}, Ljava/lang/Exception;->printStackTrace()V

    :cond_0
    return-void
.end method

.method public b(Lcom/hierynomus/smbj/smb2/d;)Ljava/util/concurrent/Future;
    .locals 4
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "<T:",
            "Lcom/hierynomus/smbj/smb2/d;",
            ">(",
            "Lcom/hierynomus/smbj/smb2/d;",
            ")",
            "Ljava/util/concurrent/Future<",
            "TT;>;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/hierynomus/smbj/transport/TransportException;
        }
    .end annotation

    .line 1
    iget-object v0, p0, Lcom/hierynomus/smbj/connection/a;->f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

    invoke-virtual {v0}, Lcom/hierynomus/smbj/connection/ConnectionInfo;->d()Lcom/hierynomus/smbj/connection/c;

    move-result-object v0

    invoke-virtual {v0}, Lcom/hierynomus/smbj/connection/c;->a()J

    move-result-wide v0

    .line 2
    invoke-virtual {p1}, Lcom/hierynomus/smbj/smb2/d;->a()Lcom/hierynomus/smbj/smb2/c;

    move-result-object v2

    invoke-virtual {v2, v0, v1}, Lcom/hierynomus/smbj/smb2/c;->a(J)V

    .line 3
    new-instance v2, Lcom/hierynomus/smbj/connection/b;

    invoke-static {}, Ljava/util/UUID;->randomUUID()Ljava/util/UUID;

    move-result-object v3

    invoke-direct {v2, v0, v1, v3, p1}, Lcom/hierynomus/smbj/connection/b;-><init>(JLjava/util/UUID;Lcom/hierynomus/smbj/smb2/d;)V

    .line 4
    iget-object v3, p0, Lcom/hierynomus/smbj/connection/a;->k:Ljava/util/concurrent/ConcurrentHashMap;

    invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v0

    invoke-virtual {v3, v0, v2}, Ljava/util/concurrent/ConcurrentHashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 5
    iget-object v0, p0, Lcom/hierynomus/smbj/connection/a;->h:Lcom/hierynomus/smbj/transport/d;

    invoke-interface {v0, p1}, Lcom/hierynomus/smbj/transport/d;->a(Lcom/hierynomus/smbj/smb2/d;)V

    const/4 p1, 0x0

    .line 6
    invoke-virtual {v2, p1}, Lcom/hierynomus/smbj/connection/b;->a(Lcom/hierynomus/smbj/connection/b$b;)Ljava/util/concurrent/Future;

    move-result-object p1

    return-object p1
.end method

.method protected g()V
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    invoke-super {p0}, Les/jd0;->g()V

    .line 2
    new-instance v0, Lcom/hierynomus/smbj/connection/ConnectionInfo;

    iget-object v1, p0, Lcom/hierynomus/smbj/connection/a;->g:Les/kd0;

    invoke-interface {v1}, Les/kd0;->b()Ljava/util/UUID;

    move-result-object v1

    invoke-virtual {p0}, Les/jd0;->e()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v0, v1, v2}, Lcom/hierynomus/smbj/connection/ConnectionInfo;-><init>(Ljava/util/UUID;Ljava/lang/String;)V

    iput-object v0, p0, Lcom/hierynomus/smbj/connection/a;->f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

    .line 3
    new-instance v0, Les/zd0;

    invoke-virtual {p0}, Les/jd0;->b()Ljava/io/InputStream;

    move-result-object v1

    invoke-direct {v0, v1, p0}, Les/zd0;-><init>(Ljava/io/InputStream;Lcom/hierynomus/smbj/transport/b;)V

    iput-object v0, p0, Lcom/hierynomus/smbj/connection/a;->i:Lcom/hierynomus/smbj/transport/c;

    .line 4
    new-instance v0, Ljava/lang/Thread;

    iget-object v1, p0, Lcom/hierynomus/smbj/connection/a;->i:Lcom/hierynomus/smbj/transport/c;

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    iput-object v0, p0, Lcom/hierynomus/smbj/connection/a;->j:Ljava/lang/Thread;

    .line 5
    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 6
    iget-object v0, p0, Lcom/hierynomus/smbj/connection/a;->h:Lcom/hierynomus/smbj/transport/d;

    invoke-virtual {p0}, Les/jd0;->b()Ljava/io/InputStream;

    move-result-object v1

    invoke-virtual {p0}, Les/jd0;->c()Ljava/io/OutputStream;

    move-result-object v2

    invoke-interface {v0, v1, v2}, Lcom/hierynomus/smbj/transport/d;->a(Ljava/io/InputStream;Ljava/io/OutputStream;)V

    .line 7
    invoke-direct {p0}, Lcom/hierynomus/smbj/connection/a;->j()V

    return-void
.end method

.method public h()V
    .locals 0
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .line 1
    invoke-super {p0}, Les/jd0;->a()V

    return-void
.end method

.method public i()Lcom/hierynomus/smbj/smb2/SMB2Dialect;
    .locals 1

    .line 1
    iget-object v0, p0, Lcom/hierynomus/smbj/connection/a;->f:Lcom/hierynomus/smbj/connection/ConnectionInfo;

    invoke-virtual {v0}, Lcom/hierynomus/smbj/connection/ConnectionInfo;->b()Lcom/hierynomus/smbj/smb2/SMB2Dialect;

    move-result-object v0

    return-object v0
.end method
